﻿using System;
using System.Web.UI;

namespace Ribbon.Web.Helper
{
    public class DynamicTemplate : ITemplate
    {
        public static ITemplate BuildUp(Action<Control> templateBuilder)
        {
            return new DynamicTemplate(templateBuilder);
        }

        private readonly Action<Control> _templateBuilder;

        public DynamicTemplate(Action<Control> templateBuilder)
        {
            _templateBuilder = templateBuilder;
        }

        #region ITemplate Members

        public void InstantiateIn(Control container)
        {
            _templateBuilder(container);
        }

        #endregion
    }
}
